<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/xadmin.css">
		<script src="js/axios.min.js"></script>
		<script src="js/vue.min.js"></script>
        <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]--></head>
    
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red"></span>账号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="phonenum" readonly  required="" lay-verify="email" autocomplete="off" class="layui-input"></div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red"></span></div></div>
                    <div class="layui-form-item">
                        <label for="L_username" class="layui-form-label">
                            <span class="x-red"></span>密码</label>
                        <div class="layui-input-inline">
                            <input type="text" id="password" readonly required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_pass" class="layui-form-label">
                            <span class="x-red"></span>身份证号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="idcardnum" required="" lay-verify="pass" autocomplete="off" class="layui-input"></div>
                        <div class="layui-form-mid layui-word-aux"></div></div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label">
                            <span class="x-red"></span>姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name"  required="" lay-verify="repass" autocomplete="off" class="layui-input"></div>
                    </div>
					 <div class="layui-form-item">
					    <label for="L_repass" class="layui-form-label">
					        <span class="x-red"></span>性别</label>
					    <div class="layui-input-inline">
					        <input type="text" id="sex"  required="" lay-verify="repass" autocomplete="off" class="layui-input"></div>
					</div>
					 <div class="layui-form-item">
					    <label for="L_repass" class="layui-form-label">
					        <span class="x-red"></span>所在省市</label>
					    <div class="layui-input-inline">
					        <input type="text" id="city"  required="" lay-verify="repass" autocomplete="off" class="layui-input"></div>
					</div>
					
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" onclick="editworker()" lay-filter="add" >保存</button></div>
               
            </div>
        </div>
        <script>
			
		   /* 截取地址中的手机号 */
		   function getUrl(){
		   	var loc = location.href;
		   	var n1 = loc.length; //地址的总长度
		   	var n2 = loc.indexOf("="); //取得=号的位置
		   	var phonenum = decodeURI(loc.substr(n2 + 1, n1 - n2)); //从=号后面的内容
		   	//alert(phonenum);
		   	return phonenum;
		   }
		   
		    /* 进入首页事件 */
		   window.onload=function(){
		   	getoneworkerxx();
		   }
		   
		   function getoneworkerxx(){
		
		   	var phonenum = getUrl();    
		   	
		   	var url = "http://129.204.188.236:8080/qiangdan/web_getoneworker/"+phonenum;
		   	
		   	 axios
		   	.post(url)
		   	.then(function(response) {
		   		console.log(response.data);
		   		
		   		//alert(response.data[0].phonenum);
				
				document.getElementById("phonenum").value = response.data[0].phonenum;
		   	    document.getElementById("password").value = response.data[0].password;
		   		document.getElementById("idcardnum").value = response.data[0].idcardnum;
				document.getElementById("name").value = response.data[0].name;
				document.getElementById("sex").value = response.data[0].sex;
				document.getElementById("city").value = response.data[0].city;
				
		   		//window.open("member-edit.html","_blank");
		   		
		   	})
		   	.catch(function(error){
		   		console.log(error);
		   	});
		   }
		   
		   function editworker(){
			   var phonenum = getUrl();    
			  
			   var idcardnum = document.getElementById("idcardnum").value;
			   var name = document.getElementById("name").value;
			   var sex = document.getElementById("sex").value;
			   var city = document.getElementById("city").value;
			   
			   var worker = {phonenum: phonenum, idcardnum: idcardnum, name: name, sex: sex, city: city};
			   
			   var url = "http://129.204.188.236:8080/qiangdan/web_editoneworker";
			   
			    axios
			   .post(url,worker)
			   .then(function(response) {
			   	console.log(response.data);
			    if(response.data == "success"){
					alert("已保存");
					location.reload();
				}else{
					alert("保存失败");
				}
			    
			   	//window.open("member-edit.html","_blank");
			   	
			   })
			   .catch(function(error){
			   	console.log(error);
			   });
		   }
			
			
			
			</script>
    </body>

</html>